package com.chenyongjing.design.pattern.composite.demo.safe;


import java.util.ArrayList;
import java.util.List;

public class Folder extends Direcotry{
    private String name;
    private Integer level;
    private List<Direcotry> dirs;

    public Folder(String name, Integer level) {
        super(name);
        this.name =name;
        this.level = level;
        this.dirs = new ArrayList<Direcotry>();
    }

    @Override
    public void show() {
        System.out.println(this.name);
        for (Direcotry dir : dirs){
            if(this.level != null){
                for(int i=0;i<this.level;i++){
                    System.out.print("   ");
                }
                for (int i=0;i<this.level;i++){
                    if(i==0){
                        System.out.print("|___");
                    }
                    System.out.print("___");
                }
            }
            dir.show();
        }
    }
    public boolean add(Direcotry direcotry){
        return this.dirs.add(direcotry);
    }

    public boolean remove(Direcotry dir){
        return this.dirs.remove(dir);
    }

    public Direcotry get(int index){
        return this.dirs.get(index);
    }


}
